<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<!--edge浏览器H5兼容设置-->
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<!--360浏览器H5兼容设置-->
		<meta name="renderer" content="webkit" />
		<title>登录</title>
		<meta name="viewport" content="width=device-width, initial-scale=1">
	</head>
	<body>

		<!--主体-->
		<div class="container mycontent text-left">
			<!--透明层 -->
			<div class="loginDiv">
				<p>用户登录</p>
				<!--表单开始-->
				<form id="form-login" action="index.html"  class="form-horizontal" role="form">
					<!--用户名-->
					<div class="form-group">
						<label for="username" class="col-md-3 control-label">名字：</label>
						<div class="col-md-8">
							<input name="username" type="text" class="form-control" id="username"  placeholder="请输入用户名">
						</div>
					</div>
					<!--密码-->
					<div class="form-group">
						<label for="password" class="col-md-3 control-label"> 密码：</label>
						<div class="col-md-8">
							<input name="password" type="text" class="form-control" id="password"  placeholder="请输入密码">
						</div>
					</div>
					<!-- 记住我-->
					<div class="form-group">
						<div class="col-md-offset-3 col-md-6">
							<div class="checkbox">
								<label>
									<input type="checkbox" id="auto">自动登录
								</label>
							</div>
						</div>
					</div>
					<!--提交按钮-->
					<div class="form-group">
						<label class="col-md-3 control-label"></label>
						<div class="col-md-8">
							<input id="btn-login" class="btn btn-primary" type="button" value="登录" />
							<span class="pull-right"><small>还没有账号？</small><a href="register.html">注册</a></span>
						</div>
					</div>
				</form>
			</div>
		</div>

	<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
	<script type="text/javascript">
	$("#btn-login").click(function() {
		$.ajax({
			"url":"/users/login",
			"data":$("#form-login").serialize(),
			"type":"post",
			"dataType":"json",
			"success":function(result) {
				if (result.state == 2000) {
					alert("登录成功！");
				} else {
					alert("登录失败！" + result.message + "！")
				}
			}
		});
	});
	</script>
	</body>
</html>









